<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
 <%@ page import="com.yaodian100.core.common.utils.ServerValue"%>
<%@ include file="/taglibs.jsp"%>
 <%
	String path = request.getContextPath();
	String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
	response.setHeader("Pragma","No-Cache");  
	response.setHeader("Cache-Control","No-Cache");  
	response.setDateHeader("Expires",   0);   
	%>
	<!-- 月历 -->
	<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick.js"></script>
	<script type="text/javascript" charset="UTF-8" src="/js/jquery.datepick-zh-CN.js"></script>
	<link rel="stylesheet" type="text/css" href="/css/smoothness.datepick.css"/>
	<!-- 時間 -->	
	<script src="/js/jquery.timePicker.js" type="text/javascript"/></script>
	<link rel="stylesheet" type="text/css" href="/css/timePicker.css"/>
	<script type="text/javascript" charset="UTF-8" src="/js/jquery.alphanumeric.js"></script>
	<script language="javascript">
	var selectArr = new Array("categorySelect","elementSelect","attributeSelect","itemSelect","unitSelect","listSelect");
	$().ready( function() {
		$('#editstartdate').datepick({minDate: null, showOn: 'both', 
	    	buttonImageOnly: true, buttonImage: '<%=ServerValue.getMidContextPath()%>/images/calendar.gif',dateFormat:"yy-mm-dd",yearRange: '-50:+50'});
		$('#editenddate').datepick({minDate: null, showOn: 'both', 
	    	buttonImageOnly: true, buttonImage: '<%=ServerValue.getMidContextPath()%>/images/calendar.gif',dateFormat:"yy-mm-dd",yearRange: '-50:+50'});
		$("#timestart").timePicker();
		$("#timeend").timePicker();
		$("#editshowseq").numeric();
		$("#editname").alphanumeric({ichars:'\'\"'});
		$("#editaliasname").alphanumeric({ichars:'\'\"'});
		$("#editGrossProfit").numeric({allow:"."});
		
	  $("#savebutton").click(function () {
    	if ($("#editname").val() == "" ){
				alert("请输入分类名称");
				return false;
			}
    	if($("#editname").val().length+chineseCount($("#editname").val())>36){
    		alert("分类名称请使用 中文18个字以内 或 英文36个字以内");
				return false;
	    }
    	if($("#editaliasname").val().length+chineseCount($("#editaliasname").val())>36){
    		alert("商品分类别名请使用 中文18个字以内 或 英文36个字以内");
				return false;
	    }
    	if ($("#editstartdate").val() == "" ){
				alert("请输入开始时间");
				return false;
			}
    	if ($("#editenddate").val() == "" ){
				alert("请输入结束时间");
				return false;
			}
    	if ($("#editshowseq").val() == "" ){
				alert("请输入显示顺序");
				return false;
		}
    	if ($("#editGrossProfit").val() == "" ){
			alert("请输入毛利率");
			return false;
		}
    	
		$("#savedataForm").submit();
	  });
	});
	function chineseCount(word){
	    var length=0;
	    for(var cc=0;cc<word.length;cc++){
	       var c = word.charCodeAt(cc);
	      if (!(c>=32&&c<=126)) length++;
	    }
	    return length;
	}

	function GetCharLength(str){
		var iLength = 0;
		for(var i = 0;i<str.length;i++)
			{
			if(str.charCodeAt(i) >255)
			{
				iLength += 2;
			}
			else
			{
				iLength += 1;
			}
		}
		return iLength;
	}
	function CutStr(Str,Len){
		var CurStr = "";
		for(var i = 0;i<Str.length;i++)
			{
				CurStr += Str.charAt(i);
			if(GetCharLength(CurStr )>Len)
			{
				return Str.substring(0,i);
			}
		}
		return CurStr ;
	} 

</script>
<s:actionerror/>
<s:actionmessage/>
<s:fielderror />
<br />
<h1>馆分类维护-编辑<br/>
<div class="f-link"><a href="searchRootData.do">回查询列表页</a></div>
</h1>
	<s:form id="savedataForm" action="saveRootData.do" method="post">
	<table>
		<tr><td>
			分类编号:${not empty category ? category.id : '依系统流水号发放'}
		</td></tr>
		<tr><td>
			分类名称:
			<input type="text" id="editname" name="editname" value="${category.name}" size="20" maxlength="14"/><span class="txt-rd">字数限制:7个中文字,14英文字</span><br>
		</td></tr>
		<tr><td>
			商品分类别名:
			<input type="text" id="editaliasname" name="editaliasname" value="${category.aliasName}" size="20" maxlength="14"/><span class="txt-rd">字数限制:7个中文字,14英文字</span><br>
		</td></tr>
		<tr><td>	
			开始时间:
			<c-rt:choose>
				<c-rt:when test="${not empty category}">
					<input type="text" id="editstartdate" name="editstartdate" value="<s:date name='category.startDate' format='yyyy-MM-dd' />"   size="10" maxlength="10"/>
					<input id="timestart" name="timestart" type="text" value="<fmt:formatDate value="${category.startDate}" pattern="HH:mm" />"   size="10" />ex:2009-12-31 00:00<br>
				</c-rt:when>
				<c-rt:otherwise>
					<input type="text" id="editstartdate" name="editstartdate" value="${editstartdate}" size="10" maxlength="10"/>
					<input id="timestart" name="timestart" type="text" size="10" value="00:00"/>ex:2009-12-31 00:00<br>
				</c-rt:otherwise>
			</c-rt:choose>
		</td></tr>
		<tr><td>	
			结束时间:
			<input type="text" id="editenddate" name="editenddate" value="<s:date name='category.endDate' format='yyyy-MM-dd' />" size="10" maxlength="10"/>
			<c-rt:choose>
				<c-rt:when test="${not empty category}">
					<input id="timeend" name="timeend" type="text" value="<fmt:formatDate value="${category.endDate}" pattern="HH:mm" />" size="10" />ex:2009-12-31 00:00<br>
				</c-rt:when>
				<c-rt:otherwise>
					<input id="timeend" name="timeend" type="text" value="00:00" size="10" />ex:2009-12-31 00:00<br>
				</c-rt:otherwise>
			</c-rt:choose>
		</td></tr>
		<tr><td>	
			显示顺序:
			<input type="text" id="editshowseq" name="editshowseq" value="${category.showSeq}" maxlength="3" size="3"/>
		</td></tr>
		<tr><td>	
			是否可见:
			<input type="radio" id="editisvisible" name="editisvisible" value="Y" <c:if test="${empty category or category.isVisible eq 'Y'}">checked="checked"</c:if>/>是
			<input type="radio" id="editisvisible" name="editisvisible" value="N" <c:if test="${category.isVisible eq 'N'}">checked="checked"</c:if>/>否
			<span class="txt-rd">※若选择『否』时会连同底下的目录也一起隐藏</span>
		</td></tr>
		<c-rt:if test="${not empty category}">
		<tr><td>	
			是否删除:
			<input type="radio" id="editisdelete" name="editisdelete" value="Y" <c:if test="${category.isDelete eq 'Y'}">checked="checked"</c:if>/>是
			<input type="radio" id="editisdelete" name="editisdelete" value="N" <c:if test="${empty category or category.isDelete eq 'N'}">checked="checked"</c:if>/>否
			<span class="txt-rd">※若选择『是』时会连同底下的目录也一起删除</span>
		</td></tr>
		</c-rt:if>				
		<tr><td>	
			部门:
			<s:select id="organization" name="editorgnizationpath" list="groups" listKey="code"  listValue="description" value="%{editorgnizationpath}"/>
		</td></tr>
		<tr><td>	
			版型编号:
			<s:select id="templatexxx" name="edittemplateid"  value="%{edittemplateid}" list="menu.options" listKey="key" listValue="value.name" /> 
		</td></tr>
		<c-rt:if test="${not empty category}">
		<tr><td>	
		建立者:${category.createUser}<br/>
		建立日期:<s:date name='category.createDate' format='yyyy-MM-dd HH:mm' /><br/>
		修改者:${category.modifyUser}<br/>
		修改日期:<s:date name='category.modifyDate' format='yyyy-MM-dd HH:mm' /><br/>
		</td></tr>
		</c-rt:if>
		<fmt-rt:formatNumber value="${category.grossProfit}" pattern="#####0.0" var="grossProfit"/>
		<tr><td>毛利率:<input id="editGrossProfit" name="editGrossProfit" size="3" type="text" value="${grossProfit}"/>%</td></tr>
		</table>
	<s:param name="id" value="#category.id"/>
	<c-rt:if test="${empty category}">
		<span class="txt-rd">※新增主馆时请记得补上该馆购物须知的HTML</span><br/>
	</c-rt:if>
	<input type="hidden" name="id" value="${category.id}"/>
		<input id="savebutton" type="button" value="Save" />
	</s:form>